package com.epam.utils;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.epam.DAO.ClientDAO;
import com.epam.entity.Client;

public class Start extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	@EJB
	private ClientDAO clientDAO;
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		resp.setContentType("text/html");
		PrintWriter out = resp.getWriter();

		out.println("<HTML><HEAD>");
		out.println("<TITLE></TITLE>");
		out.println("</HEAD><BODY>");

		List<Client> clients;

		clients = clientDAO.getAll();
		out.println("<br>");
		out.println("<br>");
		out.println("clientDAO.getAll()");
		for (Client client : clients) {
			out.println("<br>");
			out.println(client);
		}

		out.println("<br>");
		out.println("<br>");
		out.println("bla-bla");
		out.println("</BODY></HTML>");
		out.close();

	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

}
